module.exports = {
    checkLogin: function(req, res, next) {
        console.log(req.originalUrl);
        if (req.session.user) {
            next();
        } else {
            req.originalUrl? res.redirect('/user/login?u=' + req.originalUrl) : res.redirect('/user/login');
        }
    },
    checkNotLogin: function(req, res, next) {
        if (req.session.user) {
            res.redirect('/');
        } else {
            next();
        }
    },
    isLowPosition: function(req, res, next) {
        if (req.session.user.position == 6) {
            res.send('<script>alert("你没有访问当前页面的权限！")</script>');
        } else {
            next();
        }
    },
    isHighPosition: function(req, res, next) {
        if (req.session.user.position !== 6) {
            res.send('<script>alert("你没有访问当前页面的权限！")</script>');
        } else {
            next();
        }
    }
}
